package routes

import (
	"gin-project/controllers"
	"gin-project/middleware"

	"github.com/gin-gonic/gin"
)

func SetupRouter() *gin.Engine{
	r := gin.Default()
	// api 路由
	api := r.Group("/api")
	{
		//公开路由
		public := api.Group("/auth")
		{
			public.POST("/login",controllers.Login)
			public.POST("/register",controllers.Register)
		}
		//需要认证的路由
		protected := api.Group("/")
		protected.Use(middleware.AuthMiddleware())
		{
			protected.POST("/logout", controllers.Logout)
			protected.GET("/user", controllers.GetCurrentUser)
		}
	}
	return r
}